using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace EuropeEngulfed.NET
{
    partial class SplashScreen : Form
    {
        private bool fadinIn = true;
        private int waitOnFadeOut = 15;
        public SplashScreen()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!DesignMode)
            {
                Opacity = 0;
                this.fadeTimer.Enabled = true;
                this.fadeTimer.Start();
            }
        }

        private void fadeTimer_Tick(object sender, EventArgs e)
        {
            if(fadinIn)
            {
                Opacity += (fadeTimer.Interval / 1800.0);
                fadinIn = Opacity < 1.0;
            }
            else
            {
                if (waitOnFadeOut > 0)
                    waitOnFadeOut--;
                else
                {
                    Opacity -= (fadeTimer.Interval / 1800.0);
                    if (this.Opacity <= 0)
                    {
                        this.fadeTimer.Enabled = false;
                        this.fadeTimer.Stop();
                        this.Close();
                    }
                }
            }
        }
    }
}